﻿//using Microsoft.Web.WebView2.WinForms;
//using Newtonsoft.Json;
//using Newtonsoft.Json.Linq;
//using System.Net;
//using System.Net.Http.Headers;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Web;

//namespace BaiDuApiBindEmail.Core
//{
//    public class BDHttpHelper
//    {
//        //测试号
//        //jqwkcom----citufpgfyp
//        //jgfwcom----lnsqdsxkcs
//        //jva6com----rdbbtbrmbg
//        //捣窝  a002208
//        //       jz9kcom----lxeiqccqmw
//        //kbbmcom----pbskfmmvkf
//        //jystcom----qhlgodkmcw


//        //COM2----13867471545----http://sms.szfangmm.com:3000/2eNuboFBh7YorfgExDcmmg
//        //        COM4----18258438472----http://sms.szfangmm.com:3000/2eNuboFBh7YorfgExDcmmg
//        //COM6----13867466256----http://sms.szfangmm.com:3000/2eNuboFBh7YorfgExDcmmg
//        //COM8----18258437593----http://sms.szfangmm.com:3000/2eNuboFBh7YorfgExDcmmg
//        //COM13----18258432057----http://sms.szfangmm.com:3000/2eNuboFBh7YorfgExDcmmg
//        //COM14----18258437934----http://sms.szfangmm.com:3000/2eNuboFBh7YorfgExDcmmg
//        //jbtqcom----xmtcbugxvx
//        //jdnkcom----ttdyqgwevq
//        //jfqncom----kmxyctnasd
//        //k6f2com----dkgduxpvak
//        //kdbpcom----onqirbiwpn
//        //k0p5com----pgtrsnefic
//        //k8cdcom----wrnaacvpwc
//        //jm8gcom----ujqdmfmcav
//        //jbn4com----snfmsaaeig
//        //juencom----lcqjnkvciq
//        //jxa1com----lusjecphio
//        //jbmzcom----syfownoupd
//        //jtalcom----wordakpsey
//        //jmgxcom----ntyhkgkams
//        //kd1ecom----kcsgweckvs
//        //ji6jcom----ilavccuaye
//        //jiq6com----sfrkdcelne
//        //jba0com----qlsuyqlirm
//        //jjjzcom----vudwmtomsm
//        //jozbcom----yhjxneusah
//        //kbxdcom----twbaaygmpi
//        //jcdycom----cexbonuqts
//        //jyyxcom----lrdkacpwbi
//        //jbw3com----iacqvbcymi
//        //k5glcom----nrrkrvbebq
//        //k1u8com----aimwynlbbw
//        //k9yzcom----usivtmhgsr
//        //jb2hcom----yidkneyjto
//        //jb3icom----lmshyrjfog
//        //k47hcom----tomrifumgp
//        //k79kcom----dpllhxpghk
//        //jz4jcom----igrivriujc
//        //jlzjcom----rodeahixda
//        //k7fwcom----ffbtjrsvjy
//        //jokvcom----mmskbrereo
//        //jrz0com----gqqexkuuhc
//        //jt4ncom----vakpmpemnn
//        //kcfccom----xnbvglkwji
//        //kb1ocom----kjyabgqfmw


//        //        kc9acom----ydwkbdxahb
//        //jv9rcom----qfbiwndqec
//        //jd3kcom----kulxuuyvkf
//        //jdpmcom----woqorcpmvn
//        //jv5acom----ogeqnqafml
//        static string username = "jd3kcom";
//        static string ppwd = "kulxuuyvkf";
//        static string mobile = "13036112990";
//        private static HttpHelper httpHelper = new HttpHelper();

//        static Parameter parameter = new Parameter();
//        static Dictionary<string, string> results = new Dictionary<string, string>();
//        public static async Task LogingBD(WebView2 webView2)
//        {
//            // var dcode = WebUtility.UrlDecode("c9c4tF1KzuYr9qKSgJnCB3BqFaHK5bU%2FBdKHCWnIB7%2FwJ%2FPsZqIeDHayYHmxu3Wrm5qSYSezYFKvm7z3qfsVQQ");

//            await Form1.Log("获取代理IP");
//            httpHelper.MyProxy = await NetworkHelp.GetProxyIp();
//            httpHelper.MyProxy = httpHelper.MyProxy.Replace("\n", "");
//            await Form1.Log($"代理IP：{httpHelper.MyProxy}");
//            await Form1.Log("获取结束");
//            string url = string.Empty;
//            //1.访问网页
//            url = "https://passport.baidu.com/v2/?login";
//            // The cookie header string.
//            string cookieHeader = "HOSUPPORT_BFESS=1; HOSUPPORT=1; HISTORY=439af17600ad523af9a30bd642f7f8eb74195d; HISTORY_BFESS=439af17600ad523af9a30bd642f7f8eb74195d; USERNAMETYPE=1; USERNAMETYPE_BFESS=1; PSTM=1731295744; BIDUPSID=7F58F9D586BE1D2F6B2F8B5018D1935E; MCITY=-289%3A; BAIDUID=8ED8D33D988DD14F828588FD87F465DE:FG=1; H_WISE_SIDS_BFESS=60273_61027_61245_60853_61330_61371_61390_61393_61388_61402_61427; BAIDUID_BFESS=8ED8D33D988DD14F828588FD87F465DE:FG=1; ZFY=C8Z0la55FwMKIFT:BDl1md7Os5b:Bq28uZi8GsJ:BEkEjs:C; H_PS_PSSID=60273_61027_60853_61390_61468_61491_61429_61530_61612_61631_61635; RT=\"z=1&dm=baidu.com&si=77607c77-cc32-4dac-9c27-66d60ff352b3&ss=m5amnh4d&sl=1&tt=103&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=1sq&nu=uz1e7tm&cl=31z&ul=321&hd=36x\"; UBI=fi_PncwhpxZ%7ETaL96LN5VW2nJ5rdlpNTcJR1pxQqOTHRhnXTiGjCRMkasqEGkNzr1ynAYkw9C27GVM8YDBR; UBI_BFESS=fi_PncwhpxZ%7ETaL96LN5VW2nJ5rdlpNTcJR1pxQqOTHRhnXTiGjCRMkasqEGkNzr1ynAYkw9C27GVM8YDBR; BA_HECTOR=85810g010ha0018lah200k2h0ckpsh1jn6oeq1v; Hm_lvt_90056b3f84f90da57dc0f40150f005d5=1735538237,1735615371; HMACCOUNT=37FF8761D87B9F95; ppfuid=FOCoIC3q5fKa8fgJnwzbE67EJ49BGJeplOzf+4l4EOvDuu2RXBRv6R3A1AZMa49I27C0gDDLrJyxcIIeAeEhD8JYsoLTpBiaCXhLqvzbzmvy3SeAW17tKgNq/Xx+RgOdb8TWCFe62MVrDTY6lMf2GrfqL8c87KLF2qFER3obJGlcv8RcA1xQKfriWJVc7a+LGEimjy3MrXEpSuItnI4KD68SpUYZFlOs0oozjXqDVPhgbS6d5xo2o8FoKDxhrR0pBgRH3UqC3TUtxU5mr0f6cxJsVwXkGdF24AsEQ3K5XBbh9EHAWDOg2T1ejpq0s2eFy9ar/j566XqWDobGoNNfmfpaEhZpob9le2b5QIEdiQez0E9SVndeXkd9EampG0PcXhLZ126CPFCIEuj/nWa+RPzg/CQV+t396RcQ+QB5B6TasmgOrJ40n63OsKSOpoSLpklEtTKfx5hHc9j4nurRraXUHgNWSPA31ou+XTSfsKyVXVSGGnkUB7qA0khSm2nsQwBpdgqbXUb4lU+zNAV2n0AktybhhKxhReRo8jZOXronbjpyaNZANNqEA4g1HmtdHmv/tVUjVExnyBvjSrtrPu8IrnpcuigpPlr6uwWt/lm7TLIKKJqASWGtMQ6010Ekmrx4fAQe4UGeL1qFLCkLuVsqRTBoofr21/QMVXuElE6IsRNIWWghWQd3Lf4jYlSvUuymUDPSEyRa3+0Ti1dVRXtBxMNNlZL/aYKhL8ZXc31rBDqIzqGz8FaOWCcRrX7mur7xJfS8d5Pa9X6eMvvO388QS9AginaYSqZZ1qowBOLkUprNdxn+PjQUm/6IsYGfeeSSAeWd7rUjwjsqG1CAiSYEwkiM8yRL8vTnUx6p0ZJywphMm5K5yAjlzf7v15Uf7LZO9s5O64e/W4bHBcVvZlKZ/sQaRwT2P+NM288HA51bTUXyYAVuUMopdDjEpojmTGpDgbNOc8rmhct9SYps33OSur+fOpFAgP8tGwklbbh77U3jCUnOE2YVcxDRiJhV2rtoc3z07Ju637GxzfwnojhZ3atWLnGsfyEaq93vs4m7Mfxf61vQ9X5ee7c0vV+aosiH5dwXp+fI8U9TG15C1u0vKL6CrnOjCDWgWPw78v2hWygrbZr2pSYz8eskxGwuLX4n1pJ3jb5fvx8MhmCQ+Hd6nMsu/BGacBuznP9X6OXc/eBWeXCb1t/CFoW2eEU3Z0dgDDuLhCGtd3NzvuKxeKCsUJ8yoPmjElHyxoSopxWQiXzUhqx78LXpdU8o6P1c; PSINO=5; delPer=0; H_WISE_SIDS=60273_61027_60853_61390_61468_61491_61429_61530_61612_61631_61635; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; logTraceID=e4bedbeb57a5c3fda4cf34cceee7860dfb152a473cd0782969; Hm_lpvt_90056b3f84f90da57dc0f40150f005d5=1735621349; pplogid=7003lVWXURyPWsMQJFhyvKDRiGLAURCt4ePm1xOZVjSB%2FPNZ5yJMoyTy6ts5IE6uDJc32Wp8msCt5If2vvZEnPkMWsqv%2FIb9qDu%2FfySBgyIbHSE0Ci5UGb3eXt39pJgKaSoH; pplogid_BFESS=7003lVWXURyPWsMQJFhyvKDRiGLAURCt4ePm1xOZVjSB%2FPNZ5yJMoyTy6ts5IE6uDJc32Wp8msCt5If2vvZEnPkMWsqv%2FIb9qDu%2FfySBgyIbHSE0Ci5UGb3eXt39pJgKaSoH"; // 你的cookie字符串

//            // Initialize the CookieContainer.
//            CookieContainer cc = new CookieContainer();

//            // Set the cookies into the CookieContainer using the helper method.
//            SetCookiesFromHeader(cc, cookieHeader, new Uri(url));



//            httpHelper.CC = cc;
//            var resut = httpHelper.GetAndGetHtml(url, "", "", false, Encoding.UTF8, true, true);
//            results.Add(url, resut);
//            await Form1.Log($"{url}，请求完成");
//            //获取公钥
//            url = "https://passport.baidu.com/v2/getpublickey?token=&tpl=pp&subpro=&apiver=v3&tt=1736043714314&gid=285D975-C140-401D-9E6A-67515CC14F3F&loginversion=v4&traceid=&time=1736043714&alg=v3&sig=cmJSUVhNTmtEbkhzTC80VVVlU3hKTGpaSE0ySXZLeTVHRUM2ZGR5V0gwbmVGT1NvdzR2ZVhyVDgwNXFINGtpRw%3D%3D&elapsed=15&shaOne=00785aeddb8972bcc64fd4969fb7d44c5df5459d&callback=bd__cbs__npi830";

//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results.Add("getpublickey", resut);
//            await Form1.Log($"{url}，公钥获取完成");
//            //2.获取token
//            resut = await gettokensig(webView2);
//            dynamic jsonObject1 = JsonConvert.DeserializeObject(resut);
//            string sig = GetValueByJsonp(jsonObject1, "sig");
//            string shaOne = GetValueByJsonp(jsonObject1, "shaOne");
//            url = $"https://passport.baidu.com/v2/api/?getapi&token=&tpl=pp&subpro=&apiver=v3&tt=1736005987620&class=login&gid=66C5049-A125-4C4E-818C-9760A264F71D&loginversion=v4&logintype=basicLogin&traceid=&time=1736003094&alg=v3&sig={HttpUtility.UrlEncode(sig)}&elapsed=3&shaOne={HttpUtility.UrlEncode(shaOne)}&callback=bd__cbs__2fbxl";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results.Add("token", resut);
//            string token = ExtractValueFromJsonp(results["token"], "token");
//            await Form1.Log($"{token}，token获取完成");
//            //3.viewlog
//            url = "https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results.Add("viewlogOne", resut);

//            //4.会进行一次setck
//            url = "https://passport.baidu.com/static/phoenix/scripts/jssdk/all.js?v=173603973423";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results.Add("all.js", resut);
//            url = "https://passport.baidu.com/phoenix/account/osavailable?callback=baidu.phoenix._setIconsStatus";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results.Add("osavailable", resut);
//            //5.init
//            url = "https://passport.baidu.com/cap/init";
//            string body = "_=1735621353968&refer=https%3A%2F%2Fpassport.baidu.com%2Fv2%2F%3Flogin&ak=1e3f2dd1c81f2075171a547893391274&ver=2&scene=login&ds=&tk=&as=&reinit=0";
//            resut = httpHelper.PostAndGetHtml(url, body, "application/x-www-form-urlencoded; charset=UTF-8", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, null, true, true);
//            results.Add("init", resut);
//            //viewlog 
//            string as1 = ExtractValueFromJsonp(results["viewlogOne"], "as");
//            string tk = ExtractValueFromJsonp(results["viewlogOne"], "tk");
//            url = $"https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274&as={HttpUtility.U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Qx78OHXj11GNe4GLDrlKwORpqNX4AL3qTYtdxgehtppRTAYAmcXQZTpbO6Wptzb61LzksQ3RRuY%3D&tk={HttpUtility.UrlEncode(tk)}";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results["viewlogOne"] = resut;
//            as1 = ExtractValueFromJsonp(results["viewlogOne"], "as");
//            tk = ExtractValueFromJsonp(results["viewlogOne"], "tk");
//            url = $"https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274&as={HttpUtility.UrlEncode(as1)}&fs=Acj%2FXZshx3T2HuaL%2Bn6Vhtm3K5IBKmXhTXQVN3lUgM5fg%2BWicuhJ2OVZV%2F3vPBzqRqi%2BgNxp3a4yA8q%2Fcm%2BstMrMw6%2FYYcctdj9RRm675McufORqshEl1o0L0hn%2BzFKPFoklxthArBFwZDuwgEkacjq70wOahJr2aEI%2Fi6WNV0gAcbiJIgQnUsG20EE%2BmVGNDrI1y9LW1HS20ODloGwXq3v2NAeEshsoD16NH1n46PJ2%2B9YC%2Fk%2BhD4oqZIOIV5ZFTCPwj%2Fde%2F54MvAMSWABu6OcDTBmXVk4tIJ2%2F2%2FxySxToK%2BWaztpEEQcZRVnZm3RapB7hsyxN7egugDM7%2ByZn2LTEmBayyCai4Kvo9gd2rUt6SMnJfybRDCpS%2BIQSgv5fEoje2q2bZM4aQfzdQMjIr3GTCi51tb8cJaDBKzsMNTRIOzJGlUFxlFIRF33%2FHPxtEBoJZc7UTeHyjdMiqQq903kUNXBmvKxh2P0b9xijjHV%2FNwb55gsDvFm0kS66ZtuvMbJcxI2MPOb0dr13u8%2FHEH6SuVTUg6%2Ba4saDLDep927kP%2B%2B95UrJ1pNzJLCaBok5sl8WXFnVAdCkbVFgTOWIn6TKjru5Ne52O5PoB%2FzoPE7OZ5giPqYD2oUA5MgYBqU%2Bc5t7V3qxM2kwlIUTUFY8EwQxpmeUZJvW0xiv%2FKmC6EN3jUT6TiRK2KpFkYw3DFyCTrDdCNBoZVyUCOgATs94Ra2%2B83qYm%2FojAoLp5BqGEvcnyGq0%2FjIqnqfBToObyIhFCtQU6eQ91wjPTUiFRVOg9PbRwHD2HlhfiPYldzIiUnJfmDeAG1b9QB449i2HwO7yzRhpTx2oYn5d6qqe52GphVOYRO4okbWxIbfzuIcPn7b4SDmbirM9Ga5R3F7dJHpONusVI3sm4puIqF%2B8RmfCuZrTXaqR1lCUD6vwNfTwI9dFX%2FHHPnD%2BJrfshMGPXbQA79U8CQVRKQFklHKVxk34CArnD92%2FTevgQx78OHXj11GNe4GLDrlKwORpqNX4AL3qTYtdxgehtppRTAYAmcXQZTpbO6Wptzb61LzksQ3RRuY%3D&tk={HttpUtility.UrlEncode(tk)}";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results["viewlogOne"] = resut;
//            Thread.Sleep(500);
//            //检查账号
//            parameter = new Parameter()
//            {

//                username = username,
//                token = token

//            };
//            string sigruslt = await getlogchekesig(webView2, parameter);
//            dynamic jsonObject = JsonConvert.DeserializeObject(sigruslt);
//            sig = GetValueByJsonp(jsonObject, "sig");
//            shaOne = GetValueByJsonp(jsonObject, "shaOne");
//            url = $"https://passport.baidu.com/v2/api/?logincheck&token={HttpUtility.UrlEncode(token)}&tpl=pp&subpro=&apiver=v3&tt=1736041545000&sub_source=leadsetpwd&username={HttpUtility.UrlEncode(username)}&loginversion=v4&dv=tk0.74409044532953871736039734236%40vvg0ksr4PYrmKnCnx2n30psjwCnjhSrjwSBspRP3xTLHnYr4Ngpz3yosgip1gKA0Dh43BuCnjSsjh4n0IzsjwjPlJ~4X0GMugKokqipkqxSq__qg0OqpOv-AknlrmglrkvzrzqYJt0oDj7h4JwSn0pCszpSslMULyDRPRJrLlBQL37-LcgjrOtYp4viAk9grOPyruKIp4NiAknKpuglrkrxpOCYSknjp1glo4rYpOq-p4t-A2glr4CYp49gAk9ypO9-r1KnCnx2n30psjwCnjhSrjwSMXwUB5J~JnKUMlRVCcDVSq__~ssF-sFl-BEchFgBrug~AktzrC__CgrB5YgAOP-pkqxrkC-p4r~o4nzokPKpzrlrkrxpzr-rOrlhg0GsF2D-P2rWA~wg9spzP5w~Bmx19HR3BuxOLl-UBOvU8lKUMlRVA2JVM5JXFHxRMq__HgprmggAk9ip~glok9Yr4nzp1gipOCYr4nzp1gKp4rlAkN~pq__&traceid=&time=1736041545&alg=v3&sig={HttpUtility.UrlEncode(sig)}&shaOne={HttpUtility.UrlEncode(shaOne)}&rinfo=%7B%22fuid%22%3A%227c2ed2c3ac7a86272467ebb2458a22b0%22%7D&callback=bd__cbs__8c8xqn";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results["logincheck"] = resut;
//            //6.获取公钥
//            url = $"https://passport.baidu.com/v2/getpublickey?token={HttpUtility.UrlEncode(token)}&tpl=pp&subpro=&apiver=v3&tt=1735621531949&gid=25384F7-39D7-45DA-8FBF-EDD134F921EF&loginversion=v4&traceid=&time=1735621532&alg=v3&sig=aWhybGRZbyt4TlpOR0FSckRYNEtER0JEdXlDWUEvSzl3QnB3eDBwOEdXUjNiZnVJcERjTlZoNmJ3d3UxaldLQg%3D%3D&elapsed=5&shaOne=009fba49025ec13dff5a912ff9d43265d6c13b31&rinfo=%7B%22fuid%22%3A%22d2b45e1b0dbc50f31116753162ff8af4%22%7D&callback=bd__cbs__logee8";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results["getpublickey"] = resut;
//            string pubkey = ExtractValueFromJsonp(results["getpublickey"], "pubkey");
//            string pwd = await getpwd(webView2, pubkey, ppwd);
//            url = $"https://passport.baidu.com/v2/getpublickey?token={HttpUtility.UrlEncode(token)}&tpl=pp&subpro=&apiver=v3&tt=1735621531949&gid=25384F7-39D7-45DA-8FBF-EDD134F921EF&loginversion=v4&traceid=&time=1735621532&alg=v3&sig=aWhybGRZbyt4TlpOR0FSckRYNEtER0JEdXlDWUEvSzl3QnB3eDBwOEdXUjNiZnVJcERjTlZoNmJ3d3UxaldLQg%3D%3D&elapsed=5&shaOne=009fba49025ec13dff5a912ff9d43265d6c13b31&rinfo=%7B%22fuid%22%3A%22d2b45e1b0dbc50f31116753162ff8af4%22%7D&callback=bd__cbs__logee8";
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results["getpublickey"] = resut;
//            pubkey = ExtractValueFromJsonp(results["getpublickey"], "pubkey");
//            pwd = await getpwd(webView2, pubkey, ppwd);
//            //7.做下viewlog回调
//            url = "https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274&as=b5e1d81d&fs=Acj%2FXZshx3T2HuaL%2Bn6Vhtm3K5IBKmXhTXQVN3lUgM5fg%2BWicuhJ2OVZV%2F3vPBzqRqi%2BgNxp3a4yA8q%2Fcm%2BstMrMw6%2FYYcctdj9RRm675McufORqshEl1o0L0hn%2BzFKPFoklxthArBFwZDuwgEkacjq70wOahJr2aEI%2Fi6WNV0gAcbiJIgQnUsG20EE%2BmVGNDrI1y9LW1HS20ODloGwXq3v2NAeEshsoD16NH1n46PJ2%2B9YC%2Fk%2BhD4oqZIOIV5ZFTCPwj%2Fde%2F54MvAMSWABu6OcDTBmXVk4tIJ2%2F2%2FxySxToK%2BWaztpEEQcZRVnZm3RapB7hsyxN7egugDM7%2ByZn2LTEmBayyCai4Kvo9gd2rUt6SMnJfybRDCpS%2BIQSgv5fEoje2q2bZM4aQfzdQMjIr3GTCi51tb8cJaDBKzsMNTRIOzJGlUFxlFIRF33%2FHPxtEBoJZc7UTeHyjdMiqQq903kUNXBmvKxh2P0b9xijjHV%2FNwb55gsDvFm0kS66ZtuvMbJcxI2MPOb0dr13u8%2FHEH6SuVTUg6%2Ba4saDLDep927kP%2B%2B95UrJ1pNzJLCaBok5sl8WXFnVAdCkbVFgTOWIn6TKjru5Ne52O5PoB%2FzoPE7OZ5giPqYD2oUA5MgYBqU%2Bc5t7V3qxM2kwlIUTUFY8EwQxpmeUZJvW0xiv%2FKmC6EN3jUT6TiRK2KpFkYw3DFyCTrDdCNBoZVyUCOgATs94Ra2%2B83qYm%2FojAoLp5BqGEvcnyGq0%2FjIqnqfBToObyIhFCtQU6eQ91wjPTUiFRVOg9PbRwHD2HlhfiPYldzIiUnJfmDeAG1b9QB449i2HwO7yzRhpTx2oYn5d6qqe52GphVOYRO4okbWxIbfzuIcPn7b4SDmbirM9Ga5R3F7dJHpONusVI3sm4puIqF%2B8RmfCuZrTXaqR1lCUD6vwNfTwI9dFX%2FHHPnD%2BJrfshMGPXbQA79U8CQVRKQFklHKVxk34CArnD92%2FTevgQx78OHXj11GNe4GLDrlKwORpqNX4AL3qTYtdxgehtppRTAYAmcXQZTpbO6Wptzb61LzksQ3RRuY%3D&tk={0}";
//            string viewlogOne = results["viewlogOne"];
//            string tkValue = ExtractValueFromJsonp(viewlogOne, "tk");
//            url = string.Format(url, HttpUtility.UrlEncode(tkValue));
//            resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//            results.Add("viewlogtow", resut);
//            Thread.Sleep(1000);
//            //8.登录
//            url = "https://passport.baidu.com/v2/api/?login";
//            await Form1.Log($"{url}，准备登录");
//            string init = results["init"];
//            var inittk = GetValueByJsonp(init, "tk");
//            var initds = GetValueByJsonp(init, "ds");
//            string rsakey = ExtractValueFromJsonp(results["getpublickey"], "key");
//            string ds = ExtractValueFromJsonp(results["viewlogtow"], "ds");
//            string dv = await getdv(webView2);
//            dv = dv.Replace("\"", "");
//            parameter = new Parameter()
//            {
//                ds = ds,
//                username = username,
//                tk = tkValue,
//                dv = dv,
//                rsakey = rsakey,
//                password = pwd,
//                token = token

//            };
//            sigruslt = await getsig(webView2, parameter);
//            jsonObject = JsonConvert.DeserializeObject(sigruslt);
//            sig = GetValueByJsonp(jsonObject, "sig");
//            shaOne = GetValueByJsonp(jsonObject, "shaOne");
//            string traceid = await gettraceid(webView2);
//            traceid = traceid.Replace("\"", "");
//            body = "staticpage=https%3A%2F%2Fpassport.baidu.com%2Fstatic%2Fpasspc-account%2Fhtml%2Fv3Jump.html&charset=UTF-8&token={2}&tpl=pp&subpro=&apiver=v3&tt=1735980084149&codestring=&safeflg=0&u=https%3A%2F%2Fpassport.baidu.com%2F&isPhone=&detect=1&gid=7675F19-A22B-4E4F-A898-7EC2530FF660&quick_user=0&logintype=basicLogin&logLoginType=pc_loginBasic&idc=&loginmerge=true&mkey=&username={7}&password={6}&mem_pass=on&rsakey={3}&crypttype=12&ppui_logintime=253423&countrycode=&fp_uid=&fp_info=&loginversion=v4&supportdv=1&bdint_sync_cookie=&ds={4}&tk={5}&dv={11}&fuid=FOCoIC3q5fKa8fgJnwzbE67EJ49BGJeplOzf%2B4l4EOvDuu2RXBRv6R3A1AZMa49I27C0gDDLrJyxcIIeAeEhD8JYsoLTpBiaCXhLqvzbzmvy3SeAW17tKgNq%2FXx%2BRgOdb8TWCFe62MVrDTY6lMf2GrfqL8c87KLF2qFER3obJGlcv8RcA1xQKfriWJVc7a%2BLGEimjy3MrXEpSuItnI4KD1NYLg3WBiiAN5lsUOWfKL5%2FQoGFF1%2Bq%2FKQD9Lkj%2Bb9Dc7X8UF1g7r9IGAJ7BaVCtxJsVwXkGdF24AsEQ3K5XBbh9EHAWDOg2T1ejpq0s2eFy9ar%2Fj566XqWDobGoNNfmfpaEhZpob9le2b5QIEdiQez0E9SVndeXkd9EampG0PcXhLZ126CPFCIEuj%2FnWa%2BRCvURLVm4bpFOvBv8e58%2FdDOXSxFWocn8LvXoXRLp3fo5%2FfbkvdNVYtfeSgcfqcJz7tVNIB9KqyLqpAKG%2F6PN5nHZFO3SaB4GS7zlBrG2cLm8lTRl19JYcYcqvy3P%2F50mxpWDwUUC4pvKOF9e%2BpwNq7l6HzKEZyCMUDd%2BW6AiaksYiu%2B4AAz72OnMQfgAyNUbW3IyzL5c%2BUBht87WUigOY9alcIuR%2Bn1gwn%2BDmf3unATYGtv0zKmAog3Ny9wFYiQ%2FgdKSrR9D25HSwrLQyIe5QKTkKSlY6nVev8MhaT3AUPwNqYIvWCQZXWkhuuU0ZXLMYAKJSeHY7mTrwwSSKC3ZaI4k5uQVl2GgAB49Wm3WNTA3WDKZ7OXryYitGJ6nTi%2BcV0ZPdFtqNIdKPrY940QTDt91rSPWb2eeCt263%2FA%2BEJVR%2FA8%2B3BQ92SIDoXabq8Wb8ZGN9BAsC9g5OdjE6lhwzTadptHqT7mZN901gDzA4lMYEG%2FkekC%2B0J5%2FN5yVy%2Bei7UKhQHejRjxCO2%2B98Bn9oZ%2ByRR2B%2F06x2clYZDIZOXZ%2BpcZgcVUJxrUXTkrJcTxF9d7jPkj5hbBFquQKM4S%2BtDJ34jmplOTrqqKT7PPVfrdgd4OkK13pEy86BsJ8M0gKXgtivUgM8Bjl1m%2Fpkg0SuDyntWLdrmMxcZYvgySvSSwQ2Qtm8EkKHIMyR%2FXgfHnpX5vadGpRMro2qaE8u%2Bx8w1gJHIRKib2u6Q1JtQiZE1Rde%2FvRx8xKfg6uYR37n0BvfgJE5%2BKbeuwCyAvJRGUA2fpt0VClIfV0m2PRG7bvH00OODKY6cFi7NgWAK6Jc1G4Us7V80uPHCH2U89gE3WV4IIBF37aBhyiPWPAOeYXBqA&s={0}&k={1}&traceid={10}&callback=parent.bd__pcbs__ll2lkk&time=1735980084&alg=v3&sig={8}&shaOne={9}&rinfo=%7B%22fuid%22%3A%227c2ed2c3ac7a86272467ebb2458a22b0%22%7D";
//            body = string.Format(body, HttpUtility.UrlEncode(initds), HttpUtility.UrlEncode(inittk), HttpUtility.UrlEncode(token), HttpUtility.UrlEncode(rsakey), HttpUtility.UrlEncode(ds), HttpUtility.UrlEncode(tkValue), HttpUtility.UrlEncode(pwd), HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(sig), HttpUtility.UrlEncode(shaOne), HttpUtility.UrlEncode(traceid), HttpUtility.UrlEncode(dv));
//            await Form1.Log($"s:{initds}");
//            await Form1.Log($"k:{inittk}");
//            await Form1.Log($"token:{token}");
//            await Form1.Log($"rsakey:{rsakey}");
//            await Form1.Log($"ds:{ds}");
//            await Form1.Log($"pwd:{pwd}");
//            await Form1.Log($"username:{username}");
//            await Form1.Log($"sig:{sig}");
//            await Form1.Log($"shaOne:{shaOne}");
//            await Form1.Log($"traceid:{traceid}");
//            await Form1.Log($"dv:{dv}");
//            resut = httpHelper.PostAndGetHtml(url, body, "application/x-www-form-urlencoded", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, null, true, true);
//            results.Add("loginResult", resut);
//            // 定义正则表达式模式匹配lstr, ltoken, 和 bindMobileToken
//            var patternLstr = @"lstr=([^&]*)";
//            var patternLtoken = @"ltoken=([^&]*)";
//            var patternBindMobileToken = @"bindMobileToken=([^&]*)";
//            var err_no = @"err_no=([^&]*)";

//            string input = results["loginResult"];  // 将这里的your input string here替换为你的完整字符串
//                                                    // 查找匹配
//            string lstrValue = Regex.Match(input, patternLstr).Groups[1].Value;
//            string ltokenValue = Regex.Match(input, patternLtoken).Groups[1].Value;
//            string bindMobileTokenValue = Regex.Match(input, patternBindMobileToken).Groups[1].Value;
//            string err_noValue = Regex.Match(input, err_no).Groups[1].Value;
//            if (err_noValue == "25")
//            {
//                //重定向
//                // 正则表达式用于匹配 href += 后的内容
//                string pattern = "href\\s*\\+=\\s*\"(.*?)\"";

//                // 使用正则表达式进行匹配
//                Regex regex = new Regex(pattern);
//                Match match = regex.Match(input);

//                string extractedString = match.Groups[1].Value;

//                Thread.Sleep(500);

//                //重定向
//                url = $"https://passport.baidu.com/static/passpc-account/html/v3Jump.html?{extractedString}&hitWlwFreeTime=&accounts=";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results.Add("v3Jump.html", resut);

//                //初始化
//                sigruslt = await getAuthtokensig(webView2, bindMobileTokenValue, lstrValue, ltokenValue);
//                sig = GetValueByJsonp(sigruslt, "sig");
//                shaOne = GetValueByJsonp(sigruslt, "shaOne");

//                url = $"https://passport.baidu.com/v2/?bindwidget-init&token={bindMobileTokenValue}&vstr=&subpro=&lstr={lstrValue}&ltoken={ltokenValue}&u=https%3A%2F%2Fpassport.baidu.com%2F&tpl=pp&fromPv=upgradeMobile&clientfrom=pc&client=pc&isGuide=0&time=1736755651&alg=v3&sig=WUxwVVRSNDdXaS96TDQ0SlB5OFZZVG9hNWpEOUVGUDFLZWVpaFhCUE03TXJsZDF5UGU5VjJRZHFReVdndFhzQQ%3D%3D&elapsed=9&shaOne=002d41948eb6b9b169a3449275b050d4972b2bd3&rinfo=%7B%22fuid%22%3A%22d2b45e1b0dbc50f31116753162ff8af4%22%7D&callback=bd__cbs__4ibx22";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results.Add("bindwidget-init", resut);

//                //authwidgetverify
//                string authtoken = ExtractValueFromJsonp(results["bindwidget-init"], "authtoken");

//                url = $"https://passport.baidu.com/v2/sapi/authwidgetverify?bankcheck=1&authtoken={HttpUtility.UrlEncode(authtoken)}&type=&jsonp=1&apiver=v3&verifychannel=&action=getapi&vcode=&questionAndAnswer=&needsid=&rsakey=&countrycode=&subpro=&tpl=pp&winsdk=&authAction=&lang=zh-CN&callback=bd__cbs__pmhg3u";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results.Add("P_authwidgetverify", resut);

//                //getupsms

//                url = $"https://passport.baidu.com/v3/api/conf/getupsms?jsonType=1&tpl=pp&clientfrom=&client=&callback=bd__cbs__ijwt3x";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results.Add("getupsms", resut);

//                //_blank.html

//                url = $"https://passport.baidu.com/passApi/html/_blank.html";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results.Add("_blank", resut);


//                //securitygetcountrycode

//                url = $"https://passport.baidu.com/v2/?securitygetcountrycode&authtoken=&type=&jsonp=1&apiver=v3&verifychannel=&vcode=&questionAndAnswer=&needsid=&rsakey=&countrycode=&subpro=&tpl=pp&winsdk=&authAction=&lang=zh-CN&callback=bd__cbs__811gqs";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results.Add("securitygetcountrycode", resut);
//                //viewlog

//                as1 = ExtractValueFromJsonp(results["viewlogOne"], "as");
//                tk = ExtractValueFromJsonp(results["viewlogOne"], "tk");
//                url = $"https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274&as={HttpUtility.UrlEncode(as1)}&fs=Acj%2FXZshx3T2HuaL%2Bn6Vhtm3K5IBKmXhTXQVN3lUgM5fg%2BWicuhJ2OVZV%2F3vPBzqRqi%2BgNxp3a4yA8q%2Fcm%2BstMrMw6%2FYYcctdj9RRm675McufORqshEl1o0L0hn%2BzFKPFoklxthArBFwZDuwgEkacjq70wOahJr2aEI%2Fi6WNV0gAcbiJIgQnUsG20EE%2BmVGNDrI1y9LW1HS20ODloGwXq3v2NAeEshsoD16NH1n46PJ2%2B9YC%2Fk%2BhD4oqZIOIV5ZFTCPwj%2Fde%2F54MvAMSWABu6OcDTBmXVk4tIJ2%2F2%2FxySxToK%2BWaztpEEQcZRVnZm3RapB7hsyxN7egugDM7%2ByZn2LTEmBayyCai4Kvo9gd2rUt6SMnJfybRDCpS%2BIQSgv5fEoje2q2bZM4aQfzdQMjIr3GTCi51tb8cJaDBKzsMNTRIOzJGlUFxlFIRF33%2FHPxtEBoJZc7UTeHyjdMiqQq903kUNXBmvKxh2P0b9xijjHV%2FNwb55gsDvFm0kS66ZtuvMbJcxI2MPOb0dr13u8%2FHEH6SuVTUg6%2Ba4saDLDep927kP%2B%2B95UrJ1pNzJLCaBok5sl8WXFnVAdCkbVFgTOWIn6TKjru5Ne52O5PoB%2FzoPE7OZ5giPqYD2oUA5MgYBqU%2Bc5t7V3qxM2kwlIUTUFY8EwQxpmeUZJvW0xiv%2FKmC6EN3jUT6TiRK2KpFkYw3DFyCTrDdCNBoZVyUCOgATs94Ra2%2B83qYm%2FojAoLp5BqGEvcnyGq0%2FjIqnqfBToObyIhFCtQU6eQ91wjPTUiFRVOg9PbRwHD2HlhfiPYldzIiUnJfmDeAG1b9QB449i2HwO7yzRhpTx2oYn5d6qqe52GphVOYRO4okbWxIbfzuIcPn7b4SDmbirM9Ga5R3F7dJHpONusVI3sm4puIqF%2B8RmfCuZrTXaqR1lCUD6vwNfTwI9dFX%2FHHPnD%2BJrfshMGPXbQA79U8CQVRKQFklHKVxk34CArnD92%2FTevgQx78OHXj11GNe4GLDrlKwORpqNX4AL3qTYtdxgehtppRTAYAmcXQZTpbO6Wptzb61LzksQ3RRuY%3D&tk={HttpUtility.UrlEncode(tk)}";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results["viewlogOne"] = resut;

//                //获取公钥
//                url = $"https://passport.baidu.com/v2/getpublickey?&callback=bd__cbs__hpj10h";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results["getpublickey"] = resut;
//                pubkey = ExtractValueFromJsonp(results["getpublickey"], "pubkey");
//                string vcode = await getpwd(webView2, pubkey, ppwd);

//                Thread.Sleep(1000);
//                //发送密码校验
//                rsakey = ExtractValueFromJsonp(results["getpublickey"], "key");
//                url = $"https://passport.baidu.com/v2/sapi/authwidgetverify?authtoken={HttpUtility.UrlEncode(authtoken)}&type=password&jsonp=1&apiver=v3&verifychannel=&action=check&vcode={HttpUtility.UrlEncode(vcode)}&questionAndAnswer=&needsid=&rsakey={HttpUtility.UrlEncode(rsakey)}&countrycode=&subpro=&tpl=pp&winsdk=&authAction=&lang=zh-CN&callback=bd__cbs__8mohce";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results["authwidgetverify"] = resut;

//                //发送验证码之前的处理
//                url = $"https://passport.baidu.com/passApi/html/_blank.html";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results["_blank.html"] = resut;

//                //viewlog 
//                as1 = ExtractValueFromJsonp(results["viewlogOne"], "as");
//                tk = ExtractValueFromJsonp(results["viewlogOne"], "tk");
//                url = $"https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274&as={HttpUtility.UrlEncode(as1)}&fs=Acj%2FXZshx3T2HuaL%2Bn6Vhtm3K5IBKmXhTXQVN3lUgM5fg%2BWicuhJ2OVZV%2F3vPBzqRqi%2BgNxp3a4yA8q%2Fcm%2BstMrMw6%2FYYcctdj9RRm675McufORqshEl1o0L0hn%2BzFKPFoklxthArBFwZDuwgEkacjq70wOahJr2aEI%2Fi6WNV0gAcbiJIgQnUsG20EE%2BmVGNDrI1y9LW1HS20ODloGwXq3v2NAeEshsoD16NH1n46PJ2%2B9YC%2Fk%2BhD4oqZIOIV5ZFTCPwj%2Fde%2F54MvAMSWABu6OcDTBmXVk4tIJ2%2F2%2FxySxToK%2BWaztpEEQcZRVnZm3RapB7hsyxN7egugDM7%2ByZn2LTEmBayyCai4Kvo9gd2rUt6SMnJfybRDCpS%2BIQSgv5fEoje2q2bZM4aQfzdQMjIr3GTCi51tb8cJaDBKzsMNTRIOzJGlUFxlFIRF33%2FHPxtEBoJZc7UTeHyjdMiqQq903kUNXBmvKxh2P0b9xijjHV%2FNwb55gsDvFm0kS66ZtuvMbJcxI2MPOb0dr13u8%2FHEH6SuVTUg6%2Ba4saDLDep927kP%2B%2B95UrJ1pNzJLCaBok5sl8WXFnVAdCkbVFgTOWIn6TKjru5Ne52O5PoB%2FzoPE7OZ5giPqYD2oUA5MgYBqU%2Bc5t7V3qxM2kwlIUTUFY8EwQxpmeUZJvW0xiv%2FKmC6EN3jUT6TiRK2KpFkYw3DFyCTrDdCNBoZVyUCOgATs94Ra2%2B83qYm%2FojAoLp5BqGEvcnyGq0%2FjIqnqfBToObyIhFCtQU6eQ91wjPTUiFRVOg9PbRwHD2HlhfiPYldzIiUnJfmDeAG1b9QB449i2HwO7yzRhpTx2oYn5d6qqe52GphVOYRO4okbWxIbfzuIcPn7b4SDmbirM9Ga5R3F7dJHpONusVI3sm4puIqF%2B8RmfCuZrTXaqR1lCUD6vwNfTwI9dFX%2FHHPnD%2BJrfshMGPXbQA79U8CQVRKQFklHKVxk34CArnD92%2FTevgQx78OHXj11GNe4GLDrlKwORpqNX4AL3qTYtdxgehtppRTAYAmcXQZTpbO6Wptzb61LzksQ3RRuY%3D&tk={HttpUtility.UrlEncode(tk)}";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results["viewlogOne"] = resut;
//                as1 = ExtractValueFromJsonp(results["viewlogOne"], "as");
//                tk = ExtractValueFromJsonp(results["viewlogOne"], "tk");
//                url = $"https://passport.baidu.com/viewlog?callback=jQuery110205852605192997851_1735538307934&ak=1e3f2dd1c81f2075171a547893391274&as={HttpUtility.UrlEncode(as1)}&fs=Acj%2FXZshx3T2HuaL%2Bn6Vhtm3K5IBKmXhTXQVN3lUgM5fg%2BWicuhJ2OVZV%2F3vPBzqRqi%2BgNxp3a4yA8q%2Fcm%2BstMrMw6%2FYYcctdj9RRm675McufORqshEl1o0L0hn%2BzFKPFoklxthArBFwZDuwgEkacjq70wOahJr2aEI%2Fi6WNV0gAcbiJIgQnUsG20EE%2BmVGNDrI1y9LW1HS20ODloGwXq3v2NAeEshsoD16NH1n46PJ2%2B9YC%2Fk%2BhD4oqZIOIV5ZFTCPwj%2Fde%2F54MvAMSWABu6OcDTBmXVk4tIJ2%2F2%2FxySxToK%2BWaztpEEQcZRVnZm3RapB7hsyxN7egugDM7%2ByZn2LTEmBayyCai4Kvo9gd2rUt6SMnJfybRDCpS%2BIQSgv5fEoje2q2bZM4aQfzdQMjIr3GTCi51tb8cJaDBKzsMNTRIOzJGlUFxlFIRF33%2FHPxtEBoJZc7UTeHyjdMiqQq903kUNXBmvKxh2P0b9xijjHV%2FNwb55gsDvFm0kS66ZtuvMbJcxI2MPOb0dr13u8%2FHEH6SuVTUg6%2Ba4saDLDep927kP%2B%2B95UrJ1pNzJLCaBok5sl8WXFnVAdCkbVFgTOWIn6TKjru5Ne52O5PoB%2FzoPE7OZ5giPqYD2oUA5MgYBqU%2Bc5t7V3qxM2kwlIUTUFY8EwQxpmeUZJvW0xiv%2FKmC6EN3jUT6TiRK2KpFkYw3DFyCTrDdCNBoZVyUCOgATs94Ra2%2B83qYm%2FojAoLp5BqGEvcnyGq0%2FjIqnqfBToObyIhFCtQU6eQ91wjPTUiFRVOg9PbRwHD2HlhfiPYldzIiUnJfmDeAG1b9QB449i2HwO7yzRhpTx2oYn5d6qqe52GphVOYRO4okbWxIbfzuIcPn7b4SDmbirM9Ga5R3F7dJHpONusVI3sm4puIqF%2B8RmfCuZrTXaqR1lCUD6vwNfTwI9dFX%2FHHPnD%2BJrfshMGPXbQA79U8CQVRKQFklHKVxk34CArnD92%2FTevgQx78OHXj11GNe4GLDrlKwORpqNX4AL3qTYtdxgehtppRTAYAmcXQZTpbO6Wptzb61LzksQ3RRuY%3D&tk={HttpUtility.UrlEncode(tk)}";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true);
//                results["viewlogOne"] = resut;

//                Thread.Sleep(2000);
//                //发送短信验证码
//                var headers = new Dictionary<string, string>
//{
//    { "Host", "passport.baidu.com" },
//    { "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" },
//    { "Accept", "*/*" },
//    { "Accept-Language", "zh-CN,zh;q=0.9" },
//    { "Cache-Control", "no-cache" },
//    { "Connection", "keep-alive" },
//    { "Pragma", "no-cache" },
//    { "Referer", "https://passport.baidu.com/v2/?login" },
//    { "Sec-Fetch-Dest", "script" },
//    { "Sec-Fetch-Mode", "no-cors" },
//    { "Sec-Fetch-Site", "same-origin" },
//    { "sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"" },
//    { "sec-ch-ua-mobile", "?0" },
//    { "sec-ch-ua-platform", "\"Windows\"" }
//};

//                string bdstoken = ExtractValueFromJsonp(results["bindwidget-init"], "bdstoken");
//                string authsid = ExtractValueFromJsonp(results["authwidgetverify"], "authsid");
//                string smsdv = await getSMSdv(webView2);
//                smsdv = smsdv.Replace("\"", "");
//                sigruslt = await getSMSsig(webView2, authsid, WebUtility.UrlDecode(lstrValue), WebUtility.UrlDecode(ltokenValue), mobile, bdstoken, smsdv);
//                smsdv = smsdv.Replace("@", WebUtility.UrlEncode("@"));
//                sig = GetValueByJsonp(sigruslt, "sig");
//                shaOne = GetValueByJsonp(sigruslt, "shaOne");
//                url = $"https://passport.baidu.com/v2/?bindwidget-send&lang=&action=bindmobile&authsid={WebUtility.UrlEncode(authsid)}&authid=&bdstoken={WebUtility.UrlEncode(bdstoken)}&vstr=&countrycode=&exchange=1&subpro=&lstr={WebUtility.UrlEncode(lstrValue)}&ltoken={WebUtility.UrlEncode(ltokenValue)}&u=https%3A%2F%2Fpassport.baidu.com%2F&tpl=pp&fromPv=upgradeMobile&clientfrom=pc&client=pc&needforceu=1&mobile={WebUtility.UrlEncode(mobile)}&isexchangeable=1&dv={smsdv}&isGuide=0&time=1736838865&alg=v3&sig={WebUtility.UrlEncode(sig)}&shaOne={WebUtility.UrlEncode(shaOne)}&rinfo=%7B%22fuid%22%3A%22d2b45e1b0dbc50f31116753162ff8af4%22%7D&callback=bd__cbs__fxbhr0";
//                resut = httpHelper.GetAndGetHtml(url, "", "https://passport.baidu.com/v2/?login", false, Encoding.UTF8, true, true, headers);
//                results.Add("bindwidget", resut);

//                // 输出结果
//                MessageBox.Show(resut + Environment.NewLine + GetCookiesAsString(httpHelper.CC, new Uri("https://passport.baidu.com/v2/?login")));
//            }

//        }
//        public async static Task<string> getSMSsig(WebView2 webView21, string authsid, string lstr, string ltoken, string mobile, string bdstoken, string dv)
//        {
//            //(ds, dv,password, rsakey, tk, token, username) 
//            var reusult = await webView21.CoreWebView2.ExecuteScriptAsync($"getSMSsig('{authsid}','{lstr}','{ltoken}','{mobile}','{bdstoken}','{dv}')");
//            return reusult;
//        }
//        public async static Task<string> getAuthtokensig(WebView2 webView21, string token, string lstr, string ltoken)
//        {
//            //(ds, dv,password, rsakey, tk, token, username) 
//            var reusult = await webView21.CoreWebView2.ExecuteScriptAsync($"getAuthtokensig('{token}','{lstr}','{ltoken}')");
//            return reusult;
//        }
//        public static string GetCookiesAsString(CookieContainer cookieContainer, Uri uri)
//        {
//            // 获取所有与指定 URI 相关的 Cookie
//            var cookieCollection = cookieContainer.GetCookies(uri);

//            // 将 Cookie 格式化为 "key=value" 的字符串
//            var cookies = cookieCollection.Cast<Cookie>()
//                .Where(c => !string.IsNullOrEmpty(c.Value)) // 过滤掉没有值的 Cookie
//                .Select(c => $"{c.Name}={WebUtility.UrlEncode(c.Value)}") // URL 编码 Cookie 值
//                .ToList();

//            // 将所有 Cookie 组合成一个字符串
//            return string.Join("; ", cookies);
//        }

//        public async static Task StarLogin()
//        {

//            HttpClient client = new HttpClient();

//            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://passport.baidu.com/v2/api/?login");

//            request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7");
//            request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9");
//            request.Headers.Add("Cache-Control", "no-cache");
//            request.Headers.Add("Connection", "keep-alive");
//            request.Headers.Add("Cookie", "BAIDUID=4FD53A4D89047F6475999FC31ECCD27E:FG=1; BAIDUID_BFESS=4FD53A4D89047F6475999FC31ECCD27E:FG=1; Hm_lvt_90056b3f84f90da57dc0f40150f005d5=1736217171; HOSUPPORT=1; HOSUPPORT_BFESS=1; HMACCOUNT=47ECB9D132945430; ppfuid=FOCoIC3q5fKa8fgJnwzbE67EJ49BGJeplOzf+4l4EOvDuu2RXBRv6R3A1AZMa49I27C0gDDLrJyxcIIeAeEhD8JYsoLTpBiaCXhLqvzbzmvy3SeAW17tKgNq/Xx+RgOdb8TWCFe62MVrDTY6lMf2GrfqL8c87KLF2qFER3obJGlcv8RcA1xQKfriWJVc7a+LGEimjy3MrXEpSuItnI4KD68SpUYZFlOs0oozjXqDVPhgbS6d5xo2o8FoKDxhrR0pBgRH3UqC3TUtxU5mr0f6cxJsVwXkGdF24AsEQ3K5XBbh9EHAWDOg2T1ejpq0s2eFy9ar/j566XqWDobGoNNfmfpaEhZpob9le2b5QIEdiQez0E9SVndeXkd9EampG0PcXhLZ126CPFCIEuj/nWa+RPzg/CQV+t396RcQ+QB5B6TasmgOrJ40n63OsKSOpoSLpklEtTKfx5hHc9j4nurRraXUHgNWSPA31ou+XTSfsKyVXVSGGnkUB7qA0khSm2nsQwBpdgqbXUb4lU+zNAV2n0AktybhhKxhReRo8jZOXronbjpyaNZANNqEA4g1HmtdHmv/tVUjVExnyBvjSrtrPu8IrnpcuigpPlr6uwWt/lm7TLIKKJqASWGtMQ6010Ekmrx4fAQe4UGeL1qFLCkLuVsqRTBoofr21/QMVXuElE6IsRNIWWghWQd3Lf4jYlSvUuymUDPSEyRa3+0Ti1dVRXtBxMNNlZL/aYKhL8ZXc31rBDqIzqGz8FaOWCcRrX7mur7xJfS8d5Pa9X6eMvvO388QS9AginaYSqZZ1qowBOLkUprNdxn+PjQUm/6IsYGfeeSSAeWd7rUjwjsqG1CAiSYEwkiM8yRL8vTnUx6p0ZJywphMm5K5yAjlzf7v15Uf7LZO9s5O64e/W4bHBcVvZlKZ/sQaRwT2P+NM288HA51bTUXyYAVuUMopdDjEpojmTGpDgbNOc8rmhct9SYps33OSur+fOpFAgP8tGwklbbh77U3jCUnOE2YVcxDRiJhV2rtoc3z07Ju637GxzfwnojhZ3atWLnGsfyEaq93vs4m7Mfxf61vQ9X5ee7c0vV+aosiH5dwXp+fI8U9TG15C1u0vKL6CrnOjCDWgWPw78v2hWygrbZr2pSYz8eskxGwuLX4n1pJ3jb5fvx8MhmCQ+Hd6nMsu/BGacBuznP9X6OXc/eBWeXCb1t/CFoW2eEU3Z0dgDDuLhCGtd3NzvuKxeKCsUJ8yoPmjElHyxoSopxWQiXzUhqx78LXpdU8o6P1c; UBI=fi_PncwhpxZ%7ETaJc%7E9YvEfnH01ZA0BF10JzqbiWach4M3CxBi7fMf1lmsmjl8QJNWg7wT8fm%7EqbrCRSsgsg; UBI_BFESS=fi_PncwhpxZ%7ETaJc%7E9YvEfnH01ZA0BF10JzqbiWach4M3CxBi7fMf1lmsmjl8QJNWg7wT8fm%7EqbrCRSsgsg; logTraceID=8a967290eab7c25f971628760a9fa82bf226734b02d497c0fb; Hm_lpvt_90056b3f84f90da57dc0f40150f005d5=1736217308; pplogid=6283l9ahJX6Dnb%2BRofcDRM7l8BECxOY3brSl%2FYSm6Egq%2Fur8oVl4NjNCUPPvOPb5TQTQS9U0SPacw9lEswSFWSg%2BRgTVTNEkF5FpRdcgJAX4zFrpA5UzLxEmacfLlmTS25a3; pplogid_BFESS=6283l9ahJX6Dnb%2BRofcDRM7l8BECxOY3brSl%2FYSm6Egq%2Fur8oVl4NjNCUPPvOPb5TQTQS9U0SPacw9lEswSFWSg%2BRgTVTNEkF5FpRdcgJAX4zFrpA5UzLxEmacfLlmTS25a3");
//            request.Headers.Add("Origin", "https://passport.baidu.com");
//            request.Headers.Add("Pragma", "no-cache");
//            request.Headers.Add("Referer", "https://passport.baidu.com/v2/?login");
//            request.Headers.Add("Sec-Fetch-Dest", "iframe");
//            request.Headers.Add("Sec-Fetch-Mode", "navigate");
//            request.Headers.Add("Sec-Fetch-Site", "same-origin");
//            request.Headers.Add("Sec-Fetch-User", "?1");
//            request.Headers.Add("Upgrade-Insecure-Requests", "1");
//            request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
//            request.Headers.Add("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
//            request.Headers.Add("sec-ch-ua-mobile", "?0");
//            request.Headers.Add("sec-ch-ua-platform", "\"Windows\"");
//            string body = "staticpage=https%3A%2F%2Fpassport.baidu.com%2Fstatic%2Fpasspc-account%2Fhtml%2Fv3Jump.html&charset=UTF-8&token=9b8fe32893db5b0961485fe5328158c1&tpl=pp&subpro=&apiver=v3&tt=1736217373490&codestring=&safeflg=0&u=https%3A%2F%2Fpassport.baidu.com%2F&isPhone=&detect=1&gid=054D5C8-C901-4A0B-945B-B1C112DB0905&quick_user=0&logintype=basicLogin&logLoginType=pc_loginBasic&idc=&loginmerge=true&mkey=&username=jgfwcom&password=KuP7M8xo7uLku34kO4A9tcwU1Hx9M2d9%2BvEddYEeVdMMCTjGDq03FnQW%2FFUrjm2MAVzuP2Lb8pVdl%2FliUEL%2F2ZFEzBjefQs2oPm2NJ8jEaU%2Fml9T3o%2BFo%2BdarobG6AL5njKPExCanGJFz6SNnseXhoS%2F2Fey%2BOHL3tMismIUagU%3D&mem_pass=on&rsakey=vYFWhKew0eNNVyJJpyWKkHTYDrYlsIBq&crypttype=12&ppui_logintime=65304&countrycode=&fp_uid=&fp_info=&loginversion=v4&supportdv=1&bdint_sync_cookie=&ds=mGN3avImEaM07eIRbNfcfp9Nsm6%2BST8dWCjvO5ltCG7u3zJoDfedQ3s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pnGU%2B19X152o89yIxAULT23ftHVFUALPKUDWeOsi8TdS6AoqnkFQUmHXy91tJOtrqlWrZwSJSr3jyuPV8gmAtIONq7N44DreqbXMuDb%2Fef53HfoGim7MsBZ%2F%2BFz%2F54C1JeOljagE%3D&traceid=FADFB701&callback=parent.bd__pcbs__y60fy6&time=1736217373&alg=v3&sig=V0xWcmhDdWFQV3JzZk5FZVNtak8vaHhRZUExYzVCNTRUanZDMTl2cnRUenVBQ1JQZzBvbW96MzlHeW5sR1RSeQ%3D%3D&elapsed=4&shaOne=00090fab7f07ca58c3b035bd4bbaa89a36b13049&rinfo=%7B%22fuid%22%3A%22d2b45e1b0dbc50f31116753162ff8af4%22%7D";
//            request.Content = new StringContent(body);
//            request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");

//            HttpResponseMessage response = await client.SendAsync(request);
//            response.EnsureSuccessStatusCode();
//            string responseBody = await response.Content.ReadAsStringAsync();
//        }

//        public async static Task<string> getSMSdv(WebView2 webView21)
//        {


//            // 构建 JavaScript 代码
//            string js = $"getSMSdv();";

//            // 执行 JavaScript 并获取结果
//            var result = await webView21.CoreWebView2.ExecuteScriptAsync(js);
//            return result;
//        }

//        public async static Task<string> getdv(WebView2 webView21)
//        {


//            // 构建 JavaScript 代码
//            string js = $"getdv();";

//            // 执行 JavaScript 并获取结果
//            var result = await webView21.CoreWebView2.ExecuteScriptAsync(js);
//            return result;
//        }

//        public async static Task<string> gettraceid(WebView2 webView21)
//        {


//            // 构建 JavaScript 代码
//            string js = $"printTraceID();";

//            // 执行 JavaScript 并获取结果
//            var result = await webView21.CoreWebView2.ExecuteScriptAsync(js);
//            return result;
//        }
//        public async static Task<string> getpwd(WebView2 webView21, string pubkey, string pwd)
//        {
//            // 对 pubkey 和 pwd 进行必要的转义，以确保它们在 JavaScript 中是安全的
//            string escapedPubkey = pubkey.Replace("\\", "\\\\").Replace("'", "\\'").Replace("\n", "\\n");
//            string escapedPwd = pwd.Replace("\\", "\\\\").Replace("'", "\\'");

//            // 构建 JavaScript 代码
//            string js = $"getpwd('{escapedPwd}', '{escapedPubkey}');";

//            // 执行 JavaScript 并获取结果
//            var result = await webView21.CoreWebView2.ExecuteScriptAsync(js);
//            return result;
//        }
//        public async static Task<string> getsig(WebView2 webView21, Parameter parameter)
//        {
//            //(ds, dv,password, rsakey, tk, token, username) 
//            var reusult = await webView21.CoreWebView2.ExecuteScriptAsync($"getloginsig('{parameter.ds}','{parameter.dv}','{parameter.password}','{parameter.rsakey}','{parameter.tk}','{parameter.token}','{parameter.username}')");
//            return reusult;
//        }

//        public async static Task<string> gettokensig(WebView2 webView21)
//        {
//            //(ds, dv,password, rsakey, tk, token, username) 
//            var reusult = await webView21.CoreWebView2.ExecuteScriptAsync($"gettoken()");
//            return reusult;
//        }

//        public async static Task<string> getlogchekesig(WebView2 webView21, Parameter parameter)
//        {
//            //(ds, dv,password, rsakey, tk, token, username) 
//            var reusult = await webView21.CoreWebView2.ExecuteScriptAsync($"getloginchecksig('{parameter.token}','{parameter.username}')");
//            return reusult;
//        }
//        public static string GetValueByJsonp(string jsonp, string key)
//        {



//            // 解析 JSON 字符串为 JObject
//            JObject jsonObject = JObject.Parse(jsonp);

//            // 检查 'data' 对象是否存在
//            if (jsonObject["data"] == null)
//            {
//                // 尝试直接从根级别获取指定键的值
//                return jsonObject.SelectToken(key).ToString();
//            }

//            // 使用 SelectToken 安全地尝试获取指定键的值
//            JToken value = jsonObject["data"].SelectToken(key);
//            if (value == null)
//                throw new KeyNotFoundException($"Key '{key}' not found in the JSON data.");

//            return value.ToString();
//        }


//        // 通用方法来解析 JSONP 格式的字符串并提取特定键的值
//        public static string ExtractValueFromJsonp(string jsonp, string key)
//        {
//            // 去除 JSONP 函数调用和括号，只保留 JSON 内容
//            int startIndex = jsonp.IndexOf('(') + 1;
//            int length = jsonp.LastIndexOf(')') - startIndex;
//            if (startIndex == 0 || length < 0)
//                throw new ArgumentException("Invalid JSONP format");

//            string jsonString = jsonp.Substring(startIndex, length);

//            // 解析 JSON 字符串为 JObject
//            JObject jsonObject = JObject.Parse(jsonString);

//            // 检查 'data' 对象是否存在
//            if (jsonObject["data"] == null)
//            {
//                // 尝试直接从根级别获取指定键的值
//                return jsonObject.SelectToken(key).ToString();
//            }

//            // 使用 SelectToken 安全地尝试获取指定键的值
//            JToken value = jsonObject["data"].SelectToken(key);
//            if (value == null)
//                throw new KeyNotFoundException($"Key '{key}' not found in the JSON data.");

//            return value.ToString();
//        }
//        public static void SetCookiesFromHeader(CookieContainer cc, string cookieHeader, Uri uri)
//        {
//            if (string.IsNullOrEmpty(cookieHeader) || uri == null)
//                return;

//            // Split the cookies by semicolon and iterate over each one.
//            var cookies = cookieHeader.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
//            foreach (var c in cookies)
//            {
//                try
//                {
//                    // Each cookie is split into name and value.
//                    var parts = c.Trim().Split(new[] { '=' }, 2);
//                    if (parts.Length != 2) continue; // Skip invalid cookies.

//                    // Create a new Cookie instance and add it to the container.
//                    var cookie = new Cookie(parts[0].Trim(), parts[1].Trim())
//                    {
//                        Domain = uri.Host, // Use the domain from the provided URI.
//                        Path = "/"         // Usually the path is "/", but you can specify a different path if needed.
//                    };
//                    cc.Add(cookie);
//                }
//                catch
//                {


//                }

//            }
//        }
//    }
//    public class Parameter
//    {
//        public string ds { get; set; }
//        public string dv { get; set; }
//        public string password { get; set; }
//        public string rsakey { get; set; }
//        public string tk { get; set; }
//        public string token { get; set; }
//        public string username { get; set; }

//    }

//}
